package com.example.springboot1.utils;

import java.security.SecureRandom;
import java.util.Random;
import java.util.stream.IntStream;
import java.util.stream.Stream;

public class RandomChartUtil {
    public static Stream<Character> getRandomSpecialChars(int count) {
        Random random = new SecureRandom();
        IntStream specialChars = random.ints(count, 33, 45);
        return specialChars.mapToObj(data -> (char) data);
    }

    public static Stream<Character> getRandomNumbers(int count) {
        Random random = new SecureRandom();
        IntStream numbers = random.ints(count, 48, 57);
        return numbers.mapToObj(data -> (char) data);
    }

    public static Stream<Character> getRandomAlphabets(int count, boolean upperCase) {
        Random random = new SecureRandom();
        IntStream characters = null;
        if (upperCase) {
            characters = random.ints(count, 65, 90);
        } else {
            characters = random.ints(count, 97, 122);
        }
        return characters.mapToObj(data -> (char) data);
    }

    public static Stream<Character> getRandomRange(int count, int start, int end) {
        Random random = new SecureRandom();
        IntStream characters = random.ints(count, start, end);
        return characters.mapToObj(data -> (char) data);
    }
}
